-
Notifications
You must be signed in to change notification settings - Fork 534
RUBY-3612 OpenTelemetry #2957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUBY-3612 OpenTelemetry #2957
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds OpenTelemetry tracing support to the MongoDB Ruby driver, enabling distributed tracing capabilities for MongoDB operations and commands following the OpenTelemetry semantic conventions for database instrumentation.
Key changes:
- New tracing infrastructure with
Mongo::Tracing::OpenTelemetry::Tracer,OperationTracer, andCommandTracerclasses - Integration of tracing into client, collection, database, and session operations
- Support for transaction span tracking and cursor context management
- Environment variable configuration for enabling tracing and query text capture
- Comprehensive test suite including unified spec tests for OpenTelemetry
Reviewed changes
Copilot reviewed 62 out of 62 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
lib/mongo/tracing.rb |
Main tracing module with factory method for creating tracers |
lib/mongo/tracing/open_telemetry/tracer.rb |
Core tracer implementation managing operation and command tracing |
lib/mongo/tracing/open_telemetry/operation_tracer.rb |
Tracer for driver-level operations with span attribute management |
lib/mongo/tracing/open_telemetry/command_tracer.rb |
Tracer for server commands with query text capture support |
lib/mongo/client.rb |
Client integration for tracer initialization and configuration |
lib/mongo/session.rb |
Transaction span lifecycle management |
lib/mongo/operation/shared/executable.rb |
Command tracing integration in operation execution |
lib/mongo/collection.rb |
Operation tracing for collection methods |
lib/mongo/collection/view/*.rb |
Tracing integration for view operations |
lib/mongo/index/view.rb |
Index operation tracing |
spec/support/tracing.rb |
Mock tracing infrastructure for testing |
spec/spec_tests/open_telemetry_spec.rb |
Unified spec test runner for OpenTelemetry |
spec/spec_tests/data/open_telemetry/**/*.yml |
Comprehensive test specifications |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
gemfiles/standard.rb
Outdated
| end | ||
| end | ||
|
|
||
| gem 'opentelemetry-api' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? It looks like opentelemetry-sdk declares opentelemtry-api as a dependency (here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thank you. Fixed.
| # | ||
| # @return [ String | nil ] the collection name, or nil if not applicable. | ||
| def collection_name(message) | ||
| case message.documents.first.keys.first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be stable? Are we guaranteed that the first key will always be the name of the command? Though, honestly, I don't have any better ideas for how to extract the command name here...
Also, perhaps it would be clearer to use the #command_name method here, which has the same logic but also does #to_s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not find a concrete statement that the first key is always the command name; however, this is so for all the documented command.
| EXCLUDED_KEYS = %w[lsid $db $clusterTime signature].freeze | ||
|
|
||
| # Ellipsis for truncated query text. | ||
| ELLIPSES = '...' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Ellipsis" (with an 'i') is a single set of three dots, e.g. '...'
"Ellipses" (with an 'e') is the plural, referring to multiple sets of three dots. E.g. "I really like ellipses... I use them everywhere..."
| ELLIPSES = '...' | |
| ELLIPSIS = '...' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
No description provided.